Jonathan Dieter [Tue, 4 Apr 2023 20:14:49 +0000 (21:14 +0100)]
Ensure memory is freed when zrealloc is called with size 0
zrealloc is supposed to handle freeing the old pointer when called, but
when called with size 0, it was not always working as expected. This
commit fixes the bug. Thanks to Agostino Sarubbo of Gentoo for providing
a bug report with a reproducible test case.
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
Jonathan Dieter [Tue, 4 Apr 2023 20:11:12 +0000 (21:11 +0100)]
Handle read_data errors correctly
The read_data function returns the number of bytes written, not a boolean,
so fix the error checking so we exit if fewer than expected bytes were
read. Thanks to Agostino Sarubbo of Gentoo for providing a bug report with
a reproducible test case.
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
Jonathan Dieter [Tue, 4 Apr 2023 20:08:50 +0000 (21:08 +0100)]
Fix read off-by-one bug in compressed int function
A malformed compressed integer would cause unzck to read one byte past the
end of the allocated memory. This commit fixes this bug. Thanks to
Agostino Sarubbo of Gentoo for providing a bug report with a reproducible
test case.
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
Khem Raj [Wed, 22 Feb 2023 22:55:07 +0000 (14:55 -0800)]
meson: Use global function in argp check
clang is optimizing away parse_opt() since its marked static and not
used in main(), make life a bit harder for clang :)
removing static now emits the global symbols to be resolved during link
and when libargp is missing the error is thrown rightly
riscv64-yoe-linux-musl-ld: /tmp/a-5ba039.o: in function `.Lpcrel_hi0':
a.c:(.text+0x44): undefined reference to `argp_state_help'
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
Jonathan Dieter [Sat, 18 Feb 2023 20:54:28 +0000 (20:54 +0000)]
Add ZCK_NO_WRITE option to disable writing to a file
There are situations where we need to recreate the zchunk header for an
uncompressed file without actually writing out the zchunk file. This
commit allows setting an `ioption`, `ZCK_NO_WRITE`, that will go through
the full process of creating the zchunk file without actually writing it
to disk, leaving you with a complete zchunk header in the end.
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
Jonathan Dieter [Mon, 6 Feb 2023 22:36:06 +0000 (22:36 +0000)]
Clarify what the primary benefit of zchunk is
zstd now offers rsync-friendly output, so mentioning that zchunk files are
efficient over rsync misses the primary benefit zchunk has, namely that
zchunk files can be downloaded efficiently from normal web servers that
support range requests (which is basically all of them, except for some
rather strange proxies).
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
James Hilliard [Wed, 4 May 2022 22:32:48 +0000 (16:32 -0600)]
zck: declare write_data as static
This needs to be declared static to avoid a symbol conflict:
io.c:(.text+0xe8): multiple definition of `write_data'; src/zck.p/zck.c.o:zck.c:(.text+0x1f4): first defined here
Jonathan Dieter [Mon, 18 Apr 2022 16:37:19 +0000 (17:37 +0100)]
Various fixes to make Coverity happy
The single high severity issue was only triggerable if we were unable to
allocate memory and involved a memory leak. The other issues all revolve
around issues like making sure we check return values of functions we call.
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
Jonathan Dieter [Sat, 12 Mar 2022 14:27:19 +0000 (14:27 +0000)]
Fix size limit in zck.c
Up to now zck.c reads the whole file into memory and then sends it to
zck_write to actually compress. This is highly inefficient, but was done
to simplify dealing with a string separator. This commit fixes this by
reading the file in chunks, and, if using a string separator, keeps track
of the matching bytes from chunk to chunk.
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
Jonathan Dieter [Sun, 20 Feb 2022 17:07:24 +0000 (17:07 +0000)]
Merge pull request #70 from zchunk/1.2.0
Release zchunk 1.2.0 with the following changes:
* Now builds for Windows
* Can set `--uncompressed` flag when creating zchunk files to also store uncompressed digests
* `zck_read_header` now indicates whether there's a dictionary and what flags are enabled in the zchunk file
* Minimum meson version required to build zchunk is now 0.53
* Switched to use GitHub actions for automated testing
* Added the following automated test environments:
* `centos-8-stream`
* `centos-9-stream`
* `ubuntu-lts`
* `windows`, both using Mamba and meson-wrap
* `macos`